﻿using System;
using System.Collections.Generic;
using Processing001.Library.Interfaces;

namespace Processing001.Library
{
    public class FunctionGenerator : IGenerator<ComplexNumber>
    {
        private int size;
        private IFunction<double> function;
        private List<ComplexNumber> input = new List<ComplexNumber>();

        public FunctionGenerator(IFunction<double> function, int size)
        {
            this.function = function;
            this.size = size;
        }

        public List<ComplexNumber> Generate()
        {
            List<ComplexNumber> result = new List<ComplexNumber>();
            for(int i = 0; i < size; i++)
            {
                double step = (Math.PI * 2 / size) * i;
                input.Add(new ComplexNumber(step, 0));
                result.Add(new ComplexNumber(function.Execute(step), 0));
            }
            return result;
        }

        public List<ComplexNumber> Input
        {
            get { return input; }
            set { input = value;}
        }
    }
}
